home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
IRIX Development Foundation 1.1 for IRIX 6.4
/
SGI IRIX 6.4 Development Foundation 1.1.iso
/
dist
/
dist6.4
/
patchSG0002420.idb
/
usr
/
include
/
pthread.h.z
/
pthread.h
Wrap
C/C++ Source or Header
|
1997-12-03
|
8KB
|
258 lines
#ifndef _PTHREAD_H_
#define _PTHREAD_H_
#ifdef __cplusplus
extern "C" {
#endif
/**************************************************************************
* *
* Copyright (C) 1996 Silicon Graphics, Inc. *
* *
* These coded instructions, statements, and computer programs contain *
* unpublished proprietary information of Silicon Graphics, Inc., and *
* are protected by Federal copyright law. They may not be disclosed *
* to third parties or copied or duplicated in any form, in whole or *
* in part, without the prior written consent of Silicon Graphics, Inc. *
* *
**************************************************************************/
/*
* POSIX 1C Threads header file
*/
#include <stddef.h>
#include <sys/time.h>
#include <signal.h>
/*
* Primitive system data types
*/
typedef __uint32_t pthread_t; /* pthread identifier */
#ifdef _PTHREAD_EXECUTIVE
typedef struct ptattr pthread_attr_t;
typedef struct mtx pthread_mutex_t;
typedef struct mtxattr pthread_mutexattr_t;
typedef struct cv pthread_cond_t;
typedef struct cvattr pthread_condattr_t;
typedef int pthread_key_t;
typedef volatile int pthread_once_t;
#else
typedef struct { long __D[5]; } pthread_attr_t; /* pthread attributes */
typedef struct { long __D[8]; } pthread_mutex_t; /* mutex data */
typedef struct { long __D[2]; } pthread_mutexattr_t; /* mutex attributes */
typedef struct { long __D[8]; } pthread_cond_t; /* condvar data */
typedef struct { long __D[2]; } pthread_condattr_t; /* condvar attributes */
typedef int pthread_key_t; /* thread specific data key */
typedef int pthread_once_t; /* dynamic package initialization */
#endif /* !_PTHREAD_EXECUTIVE */
struct sched_param;
#undef _POSIX_THREAD_PROCESS_SHARED
#define PTHREAD_PROCESS_SHARED 0
#define PTHREAD_PROCESS_PRIVATE 1
/*
* Threads
*/
/* Thread creation attributes
*/
#define _POSIX_THREAD_ATTR_STACKSIZE 1
#define _POSIX_THREAD_ATTR_STACKADDR 1
int pthread_attr_init(pthread_attr_t *);
int pthread_attr_destroy(pthread_attr_t *);
int pthread_attr_setstacksize(pthread_attr_t *, size_t);
int pthread_attr_getstacksize(const pthread_attr_t *, size_t *);
int pthread_attr_setstackaddr(pthread_attr_t *, void *);
int pthread_attr_getstackaddr(const pthread_attr_t *, void **);
int pthread_attr_setdetachstate(pthread_attr_t *, int);
int pthread_attr_getdetachstate(const pthread_attr_t *, int *);
#define PTHREAD_CREATE_JOINABLE 0
#define PTHREAD_CREATE_DETACHED 1
/* Thread scheduling attributes
*/
#define _POSIX_THREAD_PRIORITY_SCHEDULING 1
int pthread_attr_setscope(pthread_attr_t *, int);
int pthread_attr_getscope(const pthread_attr_t *, int *);
int pthread_attr_setinheritsched(pthread_attr_t *, int);
int pthread_attr_getinheritsched(const pthread_attr_t *, int *);
int pthread_attr_setschedpolicy(pthread_attr_t *, int);
int pthread_attr_getschedpolicy(const pthread_attr_t *, int *);
int pthread_attr_setschedparam(pthread_attr_t *, const struct sched_param *);
int pthread_attr_getschedparam(const pthread_attr_t *, struct sched_param *);
#define PTHREAD_SCOPE_PROCESS 0
#define PTHREAD_SCOPE_SYSTEM 1
#define PTHREAD_EXPLICIT_SCHED 0
#define PTHREAD_INHERIT_SCHED 1
/* Thread creation and control
*/
int pthread_create(pthread_t *, pthread_attr_t *, void *(*)(void *), void *);
int pthread_join(pthread_t, void **);
int pthread_detach(pthread_t);
void pthread_exit(void *);
pthread_t pthread_self(void);
#define pthread_equal(t1, t2) ((t1) == (t2))
int pthread_kill(pthread_t, int);
int pthread_sigmask(int, const sigset_t *, sigset_t *);
int pthread_once(pthread_once_t *, void (*)(void));
#define PTHREAD_ONCE_INIT 0
/* Thread scheduling control
*/
int pthread_getschedparam(pthread_t, int *, struct sched_param *);
int pthread_setschedparam(pthread_t, int, const struct sched_param *);
int pthread_getconcurrency(void);
int pthread_setconcurrency(int);
/* Thread cancellation
*/
int pthread_cancel(pthread_t);
int pthread_setcancelstate(int, int *);
int pthread_setcanceltype(int, int *);
void pthread_testcancel(void);
struct __pthread_cncl_hdlr **__pthread_cancel_list(void);
struct __pthread_cncl_hdlr {
struct __pthread_cncl_hdlr *__ptch_next;
void (*__ptch_func)(void *);
void *__ptch_arg;
};
#define pthread_cleanup_push(func, arg) \
{ /* start of cleanup scope */ \
struct __pthread_cncl_hdlr __ptch; \
struct __pthread_cncl_hdlr **__ptch_list; \
__ptch.__ptch_func = func; \
__ptch.__ptch_arg = arg; \
__ptch_list = __pthread_cancel_list(); \
__ptch.__ptch_next = *__ptch_list; \
*__ptch_list = &__ptch
#define pthread_cleanup_pop(exec) \
*__ptch_list = __ptch.__ptch_next; \
if (exec) { \
(*__ptch.__ptch_func)(__ptch.__ptch_arg); \
} \
} /* end of cleanup scope */
#define PTHREAD_CANCELED ((void *)(1L))
#define PTHREAD_CANCEL_DISABLE 0
#define PTHREAD_CANCEL_ENABLE 1
#define PTHREAD_CANCEL_ASYNCHRONOUS 0
#define PTHREAD_CANCEL_DEFERRED 1
/*
* Mutexes
*/
/* Mutex initialisation attributes
*/
int pthread_mutexattr_init(pthread_mutexattr_t *);
int pthread_mutexattr_destroy(pthread_mutexattr_t *);
#undef _POSIX_THREAD_PROCESS_SHARED
#ifdef _POSIX_THREAD_PROCESS_SHARED
int pthread_mutexattr_getpshared(const pthread_mutexattr_t *, int *);
int pthread_mutexattr_setpshared(pthread_mutexattr_t *, int);
#endif
/* Mutex scheduling attributes
*/
int pthread_mutexattr_setprotocol(pthread_mutexattr_t *, int);
int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *, int *);
int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *, int);
int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *, int *);
#define _POSIX_THREAD_PRIO_INHERIT 1
#define _POSIX_THREAD_PRIO_PROTECT 1
#define PTHREAD_PRIO_NONE 0 /* priority unaffected */
#define PTHREAD_PRIO_INHERIT 1 /* priority inheritance */
#define PTHREAD_PRIO_PROTECT 2 /* priority ceiling */
/* Mutex creation and control
*/
int pthread_mutex_init(pthread_mutex_t *, pthread_mutexattr_t *);
int pthread_mutex_destroy(pthread_mutex_t *);
int pthread_mutex_lock(pthread_mutex_t *);
int pthread_mutex_trylock(pthread_mutex_t *);
int pthread_mutex_unlock(pthread_mutex_t *);
#define PTHREAD_MUTEX_INITIALIZER { 0 }
/* Mutex scheduling control
*/
int pthread_mutex_setprioceiling(pthread_mutex_t *, int, int *);
int pthread_mutex_getprioceiling(const pthread_mutex_t *, int *);
/*
* Condition Variables
*/
/* Condition variable initialization attributes
*/
int pthread_condattr_init(pthread_condattr_t *);
int pthread_condattr_destroy(pthread_condattr_t *);
#ifdef _POSIX_THREAD_PROCESS_SHARED
int pthread_condattr_getpshared(const pthread_condattr_t *, int *);
int pthread_condattr_setpshared(pthread_condattr_t *, int);
#endif
/* Condition variable operations
*/
int pthread_cond_init(pthread_cond_t *, pthread_condattr_t *);
int pthread_cond_destroy(pthread_cond_t *);
int pthread_cond_signal(pthread_cond_t *);
int pthread_cond_broadcast(pthread_cond_t *);
int pthread_cond_wait(pthread_cond_t *, pthread_mutex_t *);
int pthread_cond_timedwait(pthread_cond_t *, pthread_mutex_t *,
const struct timespec *);
#define PTHREAD_COND_INITIALIZER { 0 }
/*
* Thread-specific data
*/
int pthread_key_create(pthread_key_t *, void (*)(void *));
int pthread_setspecific(pthread_key_t, const void *);
void *pthread_getspecific(pthread_key_t);
int pthread_key_delete(pthread_key_t);
/*
* Miscellaneous
*/
int pthread_atfork(void (*)(void), void (*)(void), void (*)(void));
/* Short term patch: destined for <sys/resource.h>
*/
#define RLIMIT_PTHREAD 8
#ifndef _SGI_MP_SOURCE
#define _SGI_MP_SOURCE
#endif
#ifdef __cplusplus
}
#endif
#endif /* !_PTHREAD_H_ */